<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul li {
            perspective: 300px;
            list-style: none;
            margin: 100px;
            width: 130px;
            height: 35px;
        }

        .box:hover {
            transform: rotateX(90deg);
        }

        .box {
            transform-style: preserve-3d;
            text-align: center;
            line-height: 30px;
            position: relative;
            width: 100%;
            height: 100%;
            transition: all .5s;
        }

        .box .after {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: pink;
            transform: translateZ(15.5px);
        }

        .box .befor {
            position: absolute;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: purple;
            transform: translateY(15.5px) rotateX(-90deg);
        }
    </style>
</head>

<body>
    <ul>
        <li>
            <div class="box">
                <div class="after">pinkls</div>
                <div class="befor">老师在这</div>
            </div>
        </li>
    </ul>
</body>

</html>